package flc.ast.adapter;

import android.view.View;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import java.util.ArrayList;
import java.util.List;

import flc.ast.R;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;
import stark.common.bean.StkResBean;

public class ZhuiAdapter extends StkProviderMultiAdapter<StkResBean> {

    public ZhuiAdapter() {
        addItemProvider(new StkSingleSpanProvider(126));
        addItemProvider(new ZhuiProvider());
    }

    private boolean isEdit;

    public void setEdit(boolean edit) {
        isEdit = edit;
    }

    private class ZhuiProvider extends BaseItemProvider<StkResBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_zhui;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, StkResBean bean) {
            Glide.with(getContext()).load(bean.getThumbUrl())
                    .into((ImageView) baseViewHolder.getView(R.id.ivZhuiItemImg));
            baseViewHolder.setText(R.id.tvZhuiItemName, bean.getName());
            if (isEdit) {
                baseViewHolder.getView(R.id.ivZhuiItemSel).setVisibility(View.VISIBLE);
                if (bean.isSelected()) {
                    baseViewHolder.setImageResource(R.id.ivZhuiItemSel, R.drawable.zhong);
                } else {
                    baseViewHolder.setImageResource(R.id.ivZhuiItemSel, R.drawable.weiz);
                }
            } else {
                baseViewHolder.getView(R.id.ivZhuiItemSel).setVisibility(View.GONE);
            }
        }
    }

}
